package homework.day03;

import java.io.*;
import java.util.Scanner;

public class UserTest {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入名字：");
        String name = sc.nextLine();
        System.out.println("请输入密码：");
        String pwd = sc.nextLine();
        System.out.println("请输入昵称：");
        String nick = sc.nextLine();
        System.out.println("请输入年龄：");
        int age = sc.nextInt();
        User u = new User( name, pwd , nick , age);
        String filename = new StringBuilder(name).insert(name.length(), ".obj").toString();
        try (
            FileOutputStream fos = new FileOutputStream(filename);
            ObjectOutputStream oos = new ObjectOutputStream(fos);
        ){
            oos.writeObject(u);
        } catch (Exception e){
            e.printStackTrace();
        }

    }
}
